# -*- coding: utf-8 -*-
# @File     : parse_data.py
# @Author   : bingjia
# @Time     : 2020/8/10 9:28
# @Desc     :

from ..api import exceptions as exc


def parse_data(data: dict, *, cls):
    """
    验证据并返回
    """
    validator = cls(data=data)
    if not validator.is_valid():
        raise exc.RequestValidationError(validator.errors)
    return validator.data
